package com.fili.core.storage;

import java.io.Serializable;

/**
 * Created by Claudiu-Florin FILIMON
 * Date: Oct 19, 2006
 * Time: 10:35:44 PM
 */
public class DataItem implements Serializable
{
    private int[] values;
    private long time;


    public long getTime()
    {
        return time;
    }

    public DataItem()
    {
        this(null);
    }

    public DataItem(DataItem item)
    {
        values = new int[DataItemType.getNumValues()];
        if (item != null)
            System.arraycopy(item.values, 0, this.values, 0, item.values.length);
        time = System.currentTimeMillis();
    }

    public int getValue(DataItemType.Index i)
    {
        return values[i.ordinal()];
    }

    public void setValue(DataItemType.Index i, int v)
    {
        values[i.ordinal()] = v;
    }

    public String toString()
    {
        String s = "[";
        for (int i = 0; i < values.length - 1; i++)
            s += values[i] + ",";
        s += values[values.length - 1] + "]";
        return s;
    }

}
